/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import java.security.Timestamp;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author Achie
 */
@Entity
@Table(name = "Live_Lesson")
public class LiveLesson {

    @Id
    @GeneratedValue
    @Column(name = "id")
    private long id;
    @ManyToOne
    private Lesson lesson;
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar date;
    @Column(name = "status")
    private String status = "not started"; //not started, started & stopped
    @Column(name = "embedStream")
    private String embedStream;
    //Other necessary attributes for the live lesson should go here to
    //..

    public LiveLesson() {
    }

    public LiveLesson(long id, Lesson lesson, String status, String embedStream) {
        this.setId(id);
        this.setLesson(lesson);
        this.setStatus(status);
        this.setEmbedStream(embedStream);
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    public String getDay() {
        return "" + date.getInstance().get(Calendar.DAY_OF_WEEK);
    }

    public String getMonth() {
        String month = "" + date.getTime().getMonth();
        return "" + date.getInstance().get(Calendar.MONTH);
    }

    public String getYear() {
        String year = "" + date.getTime().getYear();
        return "" + date.getInstance().get(Calendar.YEAR);
    }
    
    public String getHour() {
         return "" + date.getInstance().get(Calendar.HOUR);
    }
    
    public String getMinute() {
        return "" + date.getInstance().get(Calendar.MINUTE);
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the lesson
     */
    public Lesson getLesson() {
        return lesson;
    }

    /**
     * @param lesson the lesson to set
     */
    public void setLesson(Lesson lesson) {
        this.lesson = lesson;
    }

    /**
     * @return the date
     */
    public Calendar getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(int year, int month, int day, int hour, int minute) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day, hour, minute);
        //Date d = cal.getTime();

        this.date = cal;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the embedStream
     */
    public String getEmbedStream() {
        return embedStream;
    }

    /**
     * @param embedStream the embedStream to set
     */
    public void setEmbedStream(String embedStream) {
        this.embedStream = embedStream;
    }
}
